package com.windy.controller;

import com.windy.app.vo.Result;
import com.windy.service.WebSocketService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.io.IOException;

@RestController
@RequestMapping("news")
public class NewsController {

    @Resource
    private WebSocketService webSocketService;

    @GetMapping("sendMessageToUserId")
    public Result<String> sendMessage(@PathParam("message") String message, @PathParam("userId") String userId) throws IOException {
        return webSocketService.sendMessageToUserId(message,userId);
    }

    @GetMapping("sendMessageToAll")
    public Result<String> sendMessageToAll(@PathParam("message") String message) throws IOException {
        return webSocketService.sendMessageToAll(message);
    }
}
